package com.ashes.brave;

import com.ashes.telbots.service.impl.TelbotsServiceImpl;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.telegram.telegrambots.bots.DefaultBotOptions;
import org.telegram.telegrambots.meta.TelegramBotsApi;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
import org.telegram.telegrambots.updatesreceivers.DefaultBotSession;

/**
 * @author chengxuhui
 * @description 启动类
 */
@SpringBootApplication
@ComponentScan(basePackages = {"com.ashes", "org.telegram.telegrambots.meta"})
@EnableFeignClients("com.ashes")
public class BraveApplication {

    public static void main(String[] args) {
        try {
            TelegramBotsApi telegramBotsApi = new TelegramBotsApi(DefaultBotSession.class);
            DefaultBotOptions botOptions = new DefaultBotOptions();
            botOptions.setProxyHost("127.0.0.1");
            botOptions.setProxyPort(7897);

            //选择代理类型:[HTTP|SOCKS4|SOCKS5](默认:NO_PROXY)
            botOptions.setProxyType(DefaultBotOptions.ProxyType.HTTP);
            TelbotsServiceImpl bot = new TelbotsServiceImpl(botOptions);
            telegramBotsApi.registerBot(bot);
            /*  Webhook方式
			Webhook webhook = new DefaultWebhook();
			//Webhooks_目前支持的端口：443, 80, 88, 8443
			webhook.setInternalUrl("http://0.0.0.0:8443");
			TelegramBotsApi telegramBotsApi = new TelegramBotsApi(DefaultBotSession.class, webhook);
			MyWebHookBot myWebHookBot = new MyWebHookBot();
			//需要一个可以https访问的域名并转发到上面端口
			SetWebhook setWebhook = SetWebhook.builder().url("https://joelwublog.com/").build();
			telegramBotsApi.registerBot(myWebHookBot, setWebhook);
			*/
        } catch (TelegramApiException e) {
            e.printStackTrace();
        }
        SpringApplication.run(BraveApplication.class, args);
        System.out.println("                                 ,--,");
        System.out.println("   ,---,       .--.--.         ,--.'|    ,---,.  .--.--.");
        System.out.println("  '  .' \\     /  /    '.    ,--,  | :  ,'  .' | /  /    '.");
        System.out.println(" /  ;    '.  |  :  /`. / ,---.'|  : ',---.'   ||  :  /`. /");
        System.out.println(":  :       \\ ;  |  |--`  |   | : _' ||   |   .';  |  |--`");
        System.out.println(":  |  / \\   \\|  :  ;_    :   : |.'  |:   :  |-,|  :  ;_");
        System.out.println("|  :  ' ;.   :\\  \\    `. |   ' '  ; ::   |  ;/| \\  \\    `.");
        System.out.println("|  |  ;/  \\   \\`----.   \\'   |  .'. ||   :   .'  `----.   \\");
        System.out.println("'  :  | \\  \\ ,'__ \\  \\  ||   | :  | '|   |  |-,  __ \\  \\  |");
        System.out.println("|  |  '  '--' /  /`--'  /'   : |  : ;'   :  ;/| /  /`--'  /");
        System.out.println("|  :  :      '--'.     / |   | '  ,/ |   |    \\'--'.     /");
        System.out.println("|  | ,'        `--'---'  ;   : ;--'  |   :   .'  `--'---'");
        System.out.println("`--''                    |   ,/      |   | ,'");
        System.out.println("                         '---'       `----'");
        System.out.println("(♥◠‿◠)ﾉﾞ  ASHES启动成功   ლ(´ڡ`ლ)ﾞ  ");
    }
}
